//
//  XJServiceIdenityCell.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/7/7.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJServiceIdenityCell.h"

@interface XJServiceIdenityCell()
@property (nonatomic, strong) UIView *bgView;

@end

@implementation XJServiceIdenityCell

#pragma mark - 一 lazy
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
    }
    return _bgView;
}

- (UILabel *)lb1 {
    if (!_lb1) {
        _lb1 = [UILabel new];
    }
    return _lb1;
}

- (UILabel *)lb2 {
    if (!_lb2) {
        _lb2 = [UILabel new];
        _lb2.textAlignment = NSTextAlignmentRight;
    }
    return _lb2;
}



#pragma mark - 二 init
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupView];
        
        //向右箭头
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        //取消点击效果
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setupView {
    [self.contentView addSubview:self.bgView];
    
    [self.bgView addSubview:self.lb1];
    [self.bgView addSubview:self.lb2];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
    
    CGFloat k15 = 15.0;
    
    [self.lb1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView.mas_left).offset(k15);
        make.self.top.bottom.equalTo(self.bgView);
        make.width.equalTo(@(150));
    }];
    
    [self.lb2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView.mas_right).offset(-2*k15);
        make.top.bottom.equalTo(self.bgView);
        make.width.equalTo(@(100));
    }];
}


- (void)setIdStateModel:(XJIdentityStateModel *)IdStateModel {
    _IdStateModel = IdStateModel;
    
    if (IdStateModel.isCustomIdentity) {
        self.lb2.text = IdStateModel.isCustomIdentity;
    }
}

- (void)configureXJServiceIdenityCellWithModel:(XJIdentityStateModel *)model indexPath:(NSIndexPath *)indexPath {
   
    if (indexPath.row == 0 &&  model.isCustomIdentity) {
        self.lb2.text = model.isCustomIdentity;
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}








@end
